#!/usr/bin/env bash

source "$CONFIG_DIR/environment"
source "$THEME_DIR/tokyonight"

# Configure general bar appearance.
bar=(
  blur_radius="$BAR_BLUR_RADIUS"
  border_color="$BAR_BORDER_COLOR"
  color="$BAR_COLOR"
  corner_radius="$BAR_CORNER_RADIUS"
  height="$BAR_HEIGHT"
  margin="$BAR_MARGIN"
  position="$BAR_POSITION"
  padding_left="$BAR_PADDING"
  padding_right="$BAR_PADDING"
  y_offset="$BAR_Y_OFFSET"
)
sketchybar --bar "${bar[@]}"

# Configure default values for later defined items.
default=(
  background.color="$BACKGROUND_COLOR"
  background.border_color="$BACKGROUND_BORDER_COLOR"
  background.corner_radius="$BACKGROUND_CORNER_RADIUS"
  background.height="$BACKGROUND_HEIGHT"
  icon.drawing=off
  icon.font="$ICON_FONT"
  label.align="$LABEL_ALIGN"
  label.font="$LABEL_FONT"
  label.color="$LABEL_COLOR"
  label.highlight_color="$LABEL_HIGHLIGHT_COLOR"
  label.y_offset="$LABEL_Y_OFFSET"
  label.padding_left="$LABEL_PADDING"
  label.padding_right="$LABEL_PADDING"
  y_offset="$Y_OFFSET"
)
sketchybar --default "${default[@]}"

# Left
source "$ITEM_DIR/aerospace"
source "$ITEM_DIR/spacer"
source "$ITEM_DIR/front_app"

# Right
source "$ITEM_DIR/clock"

# Automatically apply configuration changes
sketchybar --hotload on

# Force all scripts to run the first time (never do this in a script)
sketchybar --update

# Initialize focused workspace
sketchybar --trigger aerospace_workspace_change FOCUSED_WORKSPACE=$(aerospace list-workspaces --focused)
